Skip to content

fix(annotations): stop two annotate runs from both superseding one statement - #74

Open
PiquelChips wants to merge 1 commit into
mainfrom
fix/serialize-supersession
Open

PiquelChips wants to merge 1 commit into
mainfrom
fix/serialize-supersession

Conversation

@PiquelChips

Copy link
Copy Markdown
Member

Two origin annotate runs by the same user, on the same revision and kind, could both read the same current statement and both supersede it. That left two current statements from one issuer, and the next annotate superseded only the newer one.

annotate (and --withdraw) now go through Annotations::supersede. It reads the current statement and issues the new one under a dedicated lock file, index/supersession, rereading the index inside the lock so it sees statements another process just issued. It can't use the index lock: commit_indexed takes a shared index lock on a new file handle, and flock conflicts within one process. The lock is per store, so workspaces sharing a store share it. A statement issued in another store, such as a clone or a CI runner over the API, still supersedes what that issuer saw there, and the design doc now says so.

Proved with statements_issued_at_once_supersede_one_another: 50 rounds of two threads racing with different verdicts. Without the lock it failed 5 out of 5 runs, and without the reread inside the lock 3 out of 3.

Reviewed with review-loop: 1 round with 2× GPT-6.1 Sol and Claude Opus 5.5. Verdict: approved

Closes #39

Note

Written by Claude Opus 5.5 in Claude Code and reviewed by GPT-6.1 Sol (via T3 Code)

Two `origin annotate` runs by one user, on the same subject and kind,
could both read the same current statement and both supersede it,
leaving two current statements from one issuer.

`Annotations::supersede` now reads the current statement and issues the
new one in one step: under an exclusive lock of its own in the index
directory, from the index read again, so it sees statements another
process just issued. The lock is not the index's: issuing takes that one
shared on another handle, which `flock` conflicts with within one
process. `annotate`, and `--withdraw`'s lookup, call it instead of
`current` followed by `issue`.

Closes #39.
@PiquelChips PiquelChips added bug Something isn't working area/storage Objects, records, packs and the record index labels Nov 13, 2026
@coderabbitai

coderabbitai Bot commented Nov 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 49 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 74d396ad-2cc5-48a8-a850-5ea47de447ef
Commits

Reviewing files that changed from the base of the PR and between 4eec972 and 152b138.

Files selected for processing: 5

  • apps/origin-src/src/annotations/mod.rs
  • apps/origin-src/src/index.rs
  • apps/origin-src/src/workspace/annotate.rs
  • apps/origin-src/src/workspace/mod.rs
  • docs/design.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/storage Objects, records, packs and the record index bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(annotations): serialize superseding an issuer's current statement

1 participant